package com.example.applicationeventdemo;

import com.example.applicationeventdemo.pojo.UserRegisteredEvent;
import com.example.applicationeventdemo.service.UserService;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableAsync;

import javax.annotation.Resource;

@SpringBootApplication
@EnableAsync
public class ApplicationEventDemoApplication implements CommandLineRunner {
    @Resource
    private UserService userService;

    public static void main(String[] args) {
        SpringApplication.run(ApplicationEventDemoApplication.class, args);
    }

    @Override
    public void run(String... args) throws Exception {
        userService.registerUser("test张三");
        //测试condition，handleUserRegisteredEvent会过滤掉非test开头用户名的消息
        userService.registerUser("张三");
        userService.userArrive("李四");
    }
}
